<!-- include tpl=head title=$page_rs.title -->
<script type="text/javascript">
$(document).ready(function(){
	var is_vcode = '<!-- if $is_vcode -->true<!-- else -->false<!-- /if -->';
	var is_cate = '{$page_rs.cate ? "true" : "false"}';
	$("#post_submit").submit(function(){
		if(!$("#title").val()){
			$.dialog.alert('{$page_rs.alias_title ? $page_rs.alias_title : "主题"}不能为空');
			return false;
		}
		if(is_cate == 'true'){
			var cate_id = $("#cate_id").val();
			if(!cate_id){
				$.dialog.alert('请选择分类');
				return false;
			}
		}
		if(is_vcode == 'true'){
			var chkcode = $("#_chkcode").val();
			if(!chkcode){
				$.dialog.alert('验证码不能为空');
				$("#update_vcode").phpok_vcode();
				return false;
			}
		}
		$(this).ajaxSubmit({
			'url':api_url('post','save'),
			'type':'post',
			'dataType':'json',
			'success':function(rs){
				if(rs.status == 'ok'){
					$.dialog.alert('内容编辑成功',function(){
						$.phpok.go(get_url('usercp','list','id={$page_rs.identifier}'));
					});
				}else{
					$.dialog.alert(rs.content,function(){
						if(is_vcode == 'true'){
							$("#update_vcode").phpok_vcode();
							$("#_chkcode").val('');
						}
					});
					return false;
				}
			}
		});
		return false;
	});
});
</script>
<div class="am-text-center am-margin am-btn-lg">编辑</div>
<form method="post" id="post_submit" class="am-form">
	<input type="hidden" name="id" id="id" value="{$page_rs.identifier}" />
	<input type="hidden" name="tid" value="{$rs.id}" />
	<div class="am-g am-form-group">
		<label class="am-u-sm-12" for="title">{$page_rs.alias_title ? $page_rs.alias_title : '主题'}</label>
		<div class="am-u-sm-12"><input type="text" name="title" id="title" value="{$rs.title}" /></div>
	</div>
	<!-- if $catelist -->
	<div class="am-g am-form-group">
		<label class="am-u-sm-12" for="title">分类</label>
		<div class="am-u-sm-12">
			<select name="cate_id" id="cate_id">
				<option value="">请选择分类……</option>
				<!-- loop from=$catelist key=$key value=$value id=$tmpid -->
				<option value="{$value.id}"{if $cate_rs.id == $value.id} selected{/if}>{$value._space}{$value.title}</option>
				<!-- /loop -->
			</select>
		</div>
	</div>
	<!-- /if -->
	<!-- loop from=$extlist key=$key value=$value -->
	<div class="am-g am-form-group">
		<label class="am-u-sm-12" for="{$value.identifier}">{$value.title}</label>
		<div class="am-u-sm-12">{$value.html}</div>
	</div>
	<!-- /loop -->
	<!-- if $is_vcode -->
	<div class="am-g am-form-group">
		<label class="am-u-sm-12" for="_chkcode">验证码：</label>
		<div class="am-u-sm-6"><input type="text" name="_chkcode" id="_chkcode" class="vcode" /></div>
		<div class="am-u-sm-6"><img src="" border="0" align="absmiddle" id="update_vcode" class="hand"></div>
		<script type="text/javascript">
		$(document).ready(function(){
			$("#update_vcode").phpok_vcode();
			//更新点击时操作
			$("#update_vcode").click(function(){
				$(this).phpok_vcode();
			});
		});
		</script>
	</div>
	<!-- /if -->
	<div class="am-margin-sm"><input type="submit" value=" 提交 " class="am-btn am-btn-block am-btn-primary" /></div>
</form>

<!-- include tpl=foot -->